#light

namespace CGraph.GraphicsGraph
(* Graph representations of the schema used to represents graphics and animation coming from
various different sources *)

open CGraph.DirectedGraph
open CGraph.Generic

/// Outgoing edges are property edges
type IDatatypeVertex = 
    interface CGraph.Generic.INamedObject
    
/// Indicates an edge to a property.  A property
/// edge on the datatype vertex exists as long as the
/// vertex's representative object exists.  
type IPropertyEdge = interface end

/// Connected from and to a property and indicates existance based on
/// parent property's value.  For example, camera type
/// exists always, but fovx only exists if camera type is perspective.
/// Outgoing edge is a property datatype edge.  The conditional edge
/// is constructed with the predicate used to test the conditional
type IConditionalPropertyEdge = 
    abstract Predicate : (obj->bool) with get

/// Vertex indicates the name of the property and links to the datatype vertex
/// Properties may have quite a few attributes (read-only, semantic, etc).
/// that change based on state of the system and thus you need to get them
/// through the data store.
type IPropertyVertex = 
    interface CGraph.Generic.INamedObject
    
/// Outgoing vertex is a datatype vertex.
type IPropertyDatatypeEdge = interface end

/// Derivation of one datatype from another.  
/// Properties of the same name are overridden by the
/// child class.
type IDeriveDatatypeEdge = interface end
    
/// Vertex collection creation mechanism
type IGraphicsGraphVertexes =
    abstract CreateDatatypeVertex : string -> IDatatypeVertex
    abstract CreatePropertyVertex : string -> IPropertyVertex
    
    
type IGraphicsGraphEdges = 
    abstract CreatePropertyEdge : IDatatypeVertex * IPropertyVertex -> IPropertyEdge
    abstract CreateConditionalEdge : IDatatypeVertex * IPropertyVertex * (obj->bool) -> IConditionalPropertyEdge
    abstract CreatePropertyDatatypeEdge : IPropertyVertex * IDatatypeVertex -> IPropertyDatatypeEdge
    /// parent*child->edge, parent's outgoing edges point to child.
    abstract CreateDerivationEdge : IDatatypeVertex * IDatatypeVertex -> IDeriveDatatypeEdge
    
    
type IGraphicsGraph =
    abstract Vertexes : IGraphicsGraphVertexes with get
    abstract Edges : IGraphicsGraphEdges with get
    
    
    
/// Using the graph, get the properties from the objects.  Unless the property is a value type
/// (string, double, double2, double3, double4, double33, double44) do not expect it to be something
/// you can cast or mess with.  Anything that might be pass by reference will probably be passed by handle
/// so that clients cannot keep objects in memory longer than they should simply by forgetting to
/// remove a reference.
type IGraphicsGraphDataStore =
    /// Returns the object of the property.  May be a list type, 
    /// in which case enumerating will be necessary.
    /// objects and collections are by-reference.
    /// doubles, matrixes, strings are by value.
    abstract GetProperty : IPropertyVertex*obj -> obj
    /// Illegal call for collection datatypes, throws on failure
    abstract SetProperty : IPropertyVertex*obj*obj -> unit